package org.hbm.mapper;

import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;



public class UserMapperTest {
	private SqlSessionFactory factory;
	@Before
	public void setUp() throws Exception {
		// 加载配置文件
		String MYBATIS_CONFIG = "mybatis.xml";
		InputStream ism = Resources.getResourceAsStream(MYBATIS_CONFIG);
		factory = new SqlSessionFactoryBuilder().build(ism);
	}
	@Test
	public void testGetUserById() throws Exception {
		SqlSession sqlSession = factory.openSession();
		UserMapper mapper = sqlSession.getMapper(UserMapper.class);
		User userById = mapper.getUserById(1);
		System.out.println(userById);
	}


}
